<?php

namespace app\admin\middleware;

use app\admin\service\Administrator;


class Login
{
    public function handle($request, \Closure $next)
    {

        $path = $request->pathinfo();
        $path = trim($path, '/');
        $path = parse_url($path)['path'];
        $path = rtrim($path, 'html');
        $path = rtrim($path, '.');

        $path_array = explode('/', $path);

        if($path_array[0] != 'login'){
            $check = Administrator::isLogin();
            if (! $check) {
                return redirect(url('admin\login\index'));
            }
        }


        return $next($request);
    }
}
